package LeetCode.SubString;

/**
 * @author : LdLtd
 * @Date : 2023/8/9
 * @Description:1281. 整数的各位积和之差
 */
public class subtract_the_product_and_sum_of_digits_of_an_integer {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.subtractProductAndSum(12));
    }
    static class Solution {
        public int subtractProductAndSum(int n) {
            int product=1,sum=0,t=0;;
            do{
                t=n%10;
                product *=t;
                sum+=t;
                n/=10;
            }while(n!=0);
            return product-sum;
        }
    }
}
